<template>
  <div class="operate-css">
    <btn-view :menuCode="menuCode" :perms="viewPerms" :btnSize="btnSize" :btnDisplay="viewDisplay" :rowData="rowData" :rowIndex="rowIndex" :deleteApi="deleteApi" :delAlertMsg="delAlertMsg" @operateBtnClick="operateBtnClick"></btn-view>
    <btn-edit :menuCode="menuCode" :perms="editPerms" :btnSize="btnSize" :btnDisplay="editDisplay" :rowData="rowData" :rowIndex="rowIndex" @operateBtnClick="operateBtnClick"></btn-edit>
    <btn-review :menuCode="menuCode" :perms="reviewPerms" :btnSize="btnSize" :btnDisplay="reviewDisplay" :rowData="rowData" :rowIndex="rowIndex" @operateBtnClick="operateBtnClick"></btn-review>
    <!-- <btn-upload :menuCode="menuCode" :perms="uploadPerms" :btnSize="btnSize" :btnDisplay="uploadDisplay" :rowData="rowData" :rowIndex="rowIndex" @uploadSuccess="uploadSuccess"></btn-upload> -->
    <slot name="button" :row="rowData" :index="rowIndex"></slot>
    <btn-del :menuCode="menuCode" :perms="delPerms" :autoDel="autoDel" :deleteApi="deleteApi" :btnSize="btnSize" :btnDisplay="delDisplay" :rowData="rowData" :rowIndex="rowIndex" @operateBtnClick="operateBtnClick"></btn-del>
  </div>
</template>

<script>
  import btnView from '@/components/button/btnView.vue'
  import btnEdit from '@/components/button/btnEdit.vue'
  import btnReview from '@/components/button/btnReview.vue'
  // import btnUpload from '@/components/button/btnUpload.vue'
  import btnDel from '@/components/button/btnDel.vue'
  const V = 'V'
  const E = 'E'
  const R = 'R'
  const U = 'U'
  const D = 'D'
  export default {
    components: {
      btnView,
      btnEdit,
      btnReview,
      // btnUpload,
      btnDel
    },
    props: {
      // 所属菜单Code-->全局唯一
      menuCode: {
        type: String,
        default: null
      },
      // 查看按钮权限标识，外部使用者传入
      viewPerms: {
        type: String,
        default: null
      },
      // 编辑按钮权限标识，外部使用者传入
      editPerms: {
        type: String,
        default: null
      },
      // 复核按钮权限标识，外部使用者传入
      reviewPerms: {
        type: String,
        default: null
      },
      // 上传按钮权限标识，外部使用者传入
      uploadPerms: {
        type: String,
        default: null
      },
      // 删除按钮权限标识，外部使用者传入
      delPerms: {
        type: String,
        default: null
      },
      // 按钮大小
      btnSize: {
        type: String,
        default: function () {
          return 'small'
        }
      },
      // 按钮显示
      operateColLayout: {
        type: String,
        default: function () {
          return `${V},${E},${R},${U},${D}`
        }
      },
      // 行数据
      rowData: {
        type: Object,
        default: function () {
          return null
        }
      },
      // 行号
      rowIndex: {
        type: Number,
        default: function () {
          return null
        }
      },
      // 删除文件API
      deleteApi: {
        type: Object,
        default: function () {
          return null
        }
      },
      // 删除窗口的提示信息
      delAlertMsg: {
        type: String,
        default: function () {
          return '此操作会删除该条数据，是否继续？'
        }
      },
      autoDel: {
        type: Boolean,
        default () {
          return true
        }
      }
    },
    data () {
      return {
      }
    },
    mounted () {
    },
    computed: {
      viewDisplay () {
        let layout = this.operateColLayout
        return layout !== null && layout !== '' && layout.indexOf(V) !== -1
      },
      editDisplay () {
        let layout = this.operateColLayout
        return layout !== null && layout !== '' && layout.indexOf(E) !== -1
      },
      reviewDisplay () {
        let layout = this.operateColLayout
        return layout !== null && layout !== '' && layout.indexOf(R) !== -1
      },
      uploadDisplay () {
        let layout = this.operateColLayout
        return layout !== null && layout !== '' && layout.indexOf(U) !== -1
      },
      delDisplay () {
        let layout = this.operateColLayout
        return layout !== null && layout !== '' && layout.indexOf(D) !== -1
      }
    },
    methods: {
      operateBtnClick (returnData) {
        this.$emit('operateBtnClick', returnData)
      },
      uploadSuccess (returnData) {
        this.$emit('uploadSuccess', returnData)
      }
    }
  }
</script>

<style>
  .operate-css {
    width: auto;
  }
</style>
